#include <bits/stdc++.h>
using namespace std;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using ll = long long;
const ll N = 1e5 + 10;
ll k;
ll l[N], r[N], e[N], idx,x;
void init()
{
    r[0]=1,l[1]=0;
    idx=2;
}
//下标k的点右边插入
void add(ll k,ll x)
{
    e[idx] = x;
    l[idx] = k;
    r[idx] = r[k];
   
    l[r[k]] = idx;
    r[k] = idx;
    idx++;
}

void remove(ll k)
{
    r[l[k]] = r[k];
    l[r[k]] = l[k];
}
void solve()
{
    init();
    ll m;
    cin >> m;
    while(m--)
    {
        string s;
        cin >> s;
        if(s=="R") {
            cin >> x;
            add(l[1], x);
        }
        else if(s=="L")
        {
            cin >> x;
            add(0,x);
        }
        else if(s=="D")
        {
            cin >> k;
            remove(k+1);
        }
        else if(s=="IL")
        {
            cin >> k >> x;
            add(l[k + 1], x);
        }
        else
        {
            cin >> k >> x;
            add(k + 1, x);
        }
    }
    for (int i = r[0]; i != 1; i = r[i])
        cout << e[i] << ' ';
}
int main()
{
    ios::sync_with_stdio(false);
    int t = 1;
   // cin >> t;
    while(t--)
    {
        solve();
    }

    return 0;
}
